﻿@model Commission.Models.Customer
@using MyResources = Commission.Resources.AppResource
@using Microsoft.AspNet.Identity

@{
    ViewBag.Title = "Edit";
}

@section MyJavascript {
    <script type="text/javascript">
    $(document).ready(function () {
        $('#SponsorUserName').autocomplete(
        {
            source: '@Url.Action("CustomerSearch", "Customer")'
        }
        );

        $('#ParentUserName').autocomplete(
        {
            source: '@Url.Action("ParentCustomerSearch", "Customer")'
        }
        );
    })
    </script>
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>@MyResources.LabelCustomerDetail</h4>

        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.CustomerID)

        <div class="form-group">
            <label class="control-label col-md-2" for="UserName">
                @MyResources.LabelUserName
            </label>

            <div class="col-md-4">
                @if (User.IsInRole("Admin"))
                {
                    @Html.TextBoxFor(model => model.UserName,
                        new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.UserName)
                }
                else
                {
                    @Html.TextBoxFor(model => model.UserName,
                        new { @class = "form-control", @readonly = "readonly" })
                    @Html.ValidationMessageFor(model => model.UserName)
                }
            </div>

            <label class="control-label col-md-2" style="width:10%" for="Gender">
                @MyResources.LabelGender
            </label>

            <div class="col-md-4" style="margin-top:6px">
                @Html.RadioButtonFor(m => m.Gender, 0) @MyResources.LabelMale&nbsp;&nbsp;
                @Html.RadioButtonFor(m => m.Gender, 1) @MyResources.LabelFemale
                @Html.ValidationMessageFor(model => model.Gender)
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="Name">
                @MyResources.LabelCustomerName
            </label>

            <div class="col-md-4">
                @Html.TextBoxFor(model => model.Name, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Name)
            </div>

            <label class="control-label col-md-2" style="width:10%" for="BirthDay">
                @MyResources.LabelBirthday
            </label>

            <div class="col-md-4">
                @Html.JQueryUI().DatepickerFor(model => model.BirthDay,
                    new { @class = "form-control-date" })
                @Html.ValidationMessageFor(model => model.BirthDay)
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="IDCard">
                @MyResources.LabelCMND
            </label>

            <div class="col-md-10">
                @Html.TextBoxFor(model => model.IDCard, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.IDCard)
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="PhoneNumber">
                @MyResources.LabelPhoneNumber
            </label>

            <div class="col-md-10">
                @Html.TextBoxFor(model => model.PhoneNumber, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.PhoneNumber, "")
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="Address">
                @MyResources.LabelAddress
            </label>

            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Address, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Address, "")
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="CustomerTypeID">
                @MyResources.LabelCustomerType
            </label>
            
            <div class="col-md-10">
                @Html.DropDownListFor(x => x.CustomerTypeID,
                    (IEnumerable<SelectListItem>)ViewBag.CustomerTypeIDs,
                    new { @class = "form-control ddlstyle", @disabled = "disabled" })
                @Html.ValidationMessageFor(model => model.CustomerTypeID)
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="SponsorUserName">
                @MyResources.LabelSponsorUserName
            </label>

            <div class="col-md-2">
                @Html.TextBoxFor(model => model.SponsorUserName,
                    new { @class = "form-control", @readonly = "readonly" })
                @Html.ValidationMessageFor(model => model.SponsorUserName)
            </div>

            @Html.TextBoxFor(model => model.SponsorName,
                new { @class = "form-control", @readonly = "readonly" })
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="ParentUserName">
                @MyResources.LabelParentUserName
            </label>

            <div class="col-md-2">
                @Html.TextBoxFor(model => model.ParentUserName,
                    new { @class = "form-control", @readonly = "readonly" })
                @Html.ValidationMessageFor(model => model.ParentUserName)

            </div>

            @Html.TextBoxFor(model => model.ParentName,
                new { @class = "form-control", @readonly = "readonly" })
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="@MyResources.LinkEdit" class="btn btn-default" />
            </div>
        </div>
        
        @Html.HiddenFor(t => t.CustomerID)
        @Html.HiddenFor(t => t.OldCustomerTypeID)
        @Html.HiddenFor(t => t.SponsorCustomerID)
        @Html.HiddenFor(t => t.CustomerTypeID)
        @Html.HiddenFor(t => t.ParentCustomerID)
        @Html.HiddenFor(t => t.UpgradeDate)
        @Html.HiddenFor(t => t.AttendantDate)
        @Html.HiddenFor(t => t.ValidDate)
    </div>
}

<div>
    @Html.ActionLink(@MyResources.LinkBackToList, "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
